﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Utilities;

namespace Repository
{
    public class MappingUtil
    {
        public static DataTable buildOwnersDataTable()
        {
            XMLGetter xmlGetter = new XMLGetter();
            xmlGetter.setXmlFilePath(Utilities.GlobalFile.MAPPING_FILENAME);
            xmlGetter.setMasterNode("SM2");
            xmlGetter.setHeaderNode("global");
            xmlGetter.setLine1Node("owners");
            xmlGetter.setLine2Node("owner");

            DataTable dtTarget = xmlGetter.getLine2NodeValues();
            DataRow drowDt = dtTarget.NewRow();
            drowDt[0] = "";
            drowDt[1] = "Please select an owner";
            dtTarget.Rows.InsertAt(drowDt, 0);
            return dtTarget;
        }

        public static DataTable buildObjectsDataTable(string strOwner)
        {
            XMLGetter xmlGetter = new XMLGetter();
            xmlGetter.setXmlFilePath(Utilities.GlobalFile.MAPPING_FILENAME);
            xmlGetter.setMasterNode("SM2");
            xmlGetter.setHeaderNode("global");
            xmlGetter.setLine1Node(strOwner);
            xmlGetter.setLine2Node("class");

            DataTable dtTarget = xmlGetter.getLine2NodeValues();
            DataRow drowDt = dtTarget.NewRow();
            drowDt[0] = "";
            drowDt[1] = "Please select an object";
            dtTarget.Rows.InsertAt(drowDt, 0);
            return dtTarget;
        }

        public static DataTable buildActionsDataTable(string strObject)
        {
            XMLGetter xmlGetter = new XMLGetter();
            xmlGetter.setXmlFilePath(Utilities.GlobalFile.MAPPING_FILENAME);
            xmlGetter.setMasterNode("SM2");
            xmlGetter.setHeaderNode("global");
            xmlGetter.setLine1Node(strObject);
            xmlGetter.setLine2Node("method");

            DataTable dtTarget = xmlGetter.getLine2NodeValues();
            DataRow drowDt = dtTarget.NewRow();
            drowDt[0] = "";
            drowDt[1] = "Please select an action";
            dtTarget.Rows.InsertAt(drowDt, 0);
            return dtTarget;
        }
    }
}
